# Copyright (c) 2017 Presto Labs Pte. Ltd.
# Author: inkyu

import hashlib
import hmac

from requests.auth import AuthBase


class ApiKeyAuth(AuthBase):
  def __init__(self, api_key: str, api_secret: str):
    self._api_key = api_key
    self._api_secret = api_secret

  def generate_signature(self, data=''):
    signature = hmac.new(self._api_secret.encode('utf8'),
                         data.encode('utf8'),
                         digestmod=hashlib.sha384).hexdigest()
    return signature
